import {
	http
} from '@/service/index.js'
import store from '@/store/index.js'
import Stringify from '@/libs/stringify.js'

export const create = async (data, config = {}) => {
	data = Stringify(data)
	data = data.replace(/%5B([^0-9])/g, '.$1').replace(/([^0-9])%5D/g, '$1')
	return await http.post(`/index/order/create`, data, config)
}

export const orderDetail = async (data, config = {}) => {

	return await http.get(`/index/order/detail`, data, config)
}

export const orderAlipay = async (data, config = {}) => {

	return await http.post(`/index/order/alipay`, data, config)
}
export const wechatPay = async (data, config = {}) => {

	return await http.post(`/index/order/wechatPay`, data, config)
}

export const orderListPage = async (data, config = {}) => {

	return await http.get(`/index/order/listPage`, data, config)
}


export const confirmReceipt = async (data, config = {}) => {
	// orderId
	return await http.post(`/index/order/confirmReceipt`, data, config)
}

export const cancelOrder = async (data, config = {}) => {
	// orderId
	return await http.post(`/index/order/cancelOrder`, data, config)
}

export const userGroupListPage = async (data, config = {}) => {
	// orderId
	return await http.get(`/index/order/userGroupListPage`, data, config)
}



export const getCanUseCoupons = async (data, config = {}) => {
	data = Stringify(data)
	data = data.replace(/%5B([^0-9])/g, '.$1').replace(/([^0-9])%5D/g, '$1')
	return await http.post(`/index/order/getCanUseCoupons`, data, config)
}
